package com.bawei.lib_base.utils.utils.utils

import com.bawei.lib_base.utils.utils.entity.*
import com.bawei.lib_base.utils.utils.res.Res
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query


interface ApiService{
    @POST("/api/user/register")
    fun register(@Query("username")username:String,@Query("password")password:String):Flow<Res<UserBean>>
    @POST("/api/user/login")
    fun login(@Query("username")username:String,@Query("password")password:String):Flow<Res<UserBean>>

    //公告
    @GET("/api/announcements")
    fun notices(@Query("page")page:Int, @Query("size")size:Int): Flow<Res<NoticeBean>>

    //车位
    @GET("/api/parking-spaces/status/{spaceStatus}")
    fun parkSpaceStatus(@Path("spaceStatus")spaceStatus : String) : Flow<Res<ParkBean>>

    @GET("/api/parking-spaces/type/{spaceType}")
    fun parkSpaceType(@Path("spaceType")spaceType : String) : Flow<Res<ParkBean>>

    @GET("/api/parking-spaces/area/{areaId}")
    fun parkArea(@Path("areaId")areaId : Int) : Flow<Res<ParkBean>>

    @GET("/api/parking-spaces/license/{licensePlate}")
    fun parkLicensePlate(@Path("licensePlate")licensePlate : String) : Flow<Res<ParkBeanItem>>

    @POST("/api/parking-spaces")
    fun parkAdd(@Body body: RequestBody) : Flow<Res<ParkBeanItem>>

    @PUT("/api/parking-spaces/{id}")
    fun parkSpaces(@Path("id")id : Int,@Body body: RequestBody) : Flow<Res<ParkBeanItem>>

    @GET("/api/parking-spaces/{id}")
    fun parkDetail(@Path("id")id : Int) : Flow<Res<ParkBean>>

    //预约来访
    @GET("/api/visit-appointments")
    fun visit() : Flow<Res<VisitBean>>

    @GET("/api/visit-appointments/status/{status}")
    fun visitStatus(@Path("status")status : String) :Flow<Res<VisitBean>>

    @GET("/api/visit-appointments/search/name")
    fun visitName(@Query("name")name : String) : Flow<Res<VisitBean>>

    @POST("/api/visit-appointments")
    fun visitAdd(@Body body: RequestBody) : Flow<Res<VisitBeanItem>>

    @GET("/api/visit-appointments/{id}")
    fun visitDetail(@Path("id")id : Int) : Flow<Res<VisitBeanItem>>

    @PATCH("/api/visit-appointments/approve/{id}")
    fun visitApprove(@Path("id")id : Int) : Flow<Res<VisitBeanItem>>

    @PATCH("/api/visit-appointments/reject/{id}")
    fun visitReject(@Path("id")id : Int) : Flow<Res<VisitBeanItem>>

    //报修工单
    @GET("/api/repair-orders")
    fun repair() : Flow<Res<RepairBean>>

    @POST("/api/repair-orders")
    fun repairAdd(@Body body: RequestBody) : Flow<Res<RepairBeanItem>>

    @GET("/api/repair-orders/order-number/{orderNumber}")
    fun repairOrderNumber(@Path("orderNumber")orderNumber : String) : Flow<Res<RepairBean>>

    @GET("/api/repair-orders/search")
    fun repairOrderSearch(@Query("repairName")repairName : String) : Flow<Res<RepairBeanItem>>

    @GET("/api/repair-orders/{id}")
    fun repairDetail(@Path("id")id : Int) :Flow<Res<RepairBeanItem>>

    @PUT("/api/repair-orders/{id}")
    fun repairOrders(@Path("id")id : Int,@Body body: RequestBody) :Flow<Res<RepairBeanItem>>

    //房源
    @GET("/api/properties")
    fun house() : Flow<Res<HouseBean>>

    @GET("/api/properties/region/{regionId}")
    fun houseRegionId(@Path("regionId")regionId : Int) : Flow<Res<HouseBean>>

    @PATCH("/api/properties/rent/{id}")
    fun houseRent(@Path("id")id : Int,@Query("rentDate")rentDate : String) : Flow<Res<HouseBeanItem>>

    @PATCH("/api/properties/unrent/{id}")
    fun houseUnRent(@Path("id")id : Int) : Flow<Res<HouseBeanItem>>
}